<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增广告 - 广告')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-info-add" th:object="${cstAdInfo}">
       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">客户端广告记录编号：</label>
            <div class="col-sm-8">
                <input name="adId" class="form-control" type="text" required>
            </div>
        </div>-->

        <div class="form-group" type="text">
            <label class="col-sm-3 control-label"  >广告位position：</label>
            <div class="col-sm-8">
                <input name="ados" id="position" class="form-control" type="text" onclick="adpost()" required>
            </div>
        </div>

        <input id="hideinfo" name="hideinfo" type="hidden">

        <!--<div class="form-group">
            <label class="col-sm-3 control-label">区域ID：</label>
            <div class="col-sm-8">
                <input name="areaId" class="form-control" type="text" required>
            </div>
        </div>-->
        <!--<div class="form-group">
            <label class="col-sm-3 control-label">排序：</label>
            <div class="col-sm-8">
                <input name="seq" class="form-control" type="text" required>
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">广告名称：</label>
            <div class="col-sm-8">
                <input name="title" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">摘要：</label>
            <div class="col-sm-8">
                <input name="description" class="form-control" type="text" required>
            </div>
        </div>
        <!--<div class="form-group">
           <label class="col-sm-3 control-label">上传广告图：</label>
            <div class="col-sm-8">
                &lt;!&ndash;<textarea name="iconUrl" class="form-control" required></textarea>&ndash;&gt;&lt;!&ndash;onchange="showImg(this)"&ndash;&gt;
                <input type="file" id="file" name="file" class="webuploader-element-invisible" multiple="multiple" >
                <img src="" alt="" id="img">
            </div>
        </div>-->

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <h4 class="form-header h4">上传图片</h4>
                    <div class="file-loading">
                        <input id="filePath" class="file" type="file" multiple data-min-file-count="1" data-theme="fas">
                    </div>
                </div>
            </div>
        </div>

       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">图片相关：</label>
            <div class="col-sm-8">
                <textarea name="image" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">路由跳转地址：</label>
            <div class="col-sm-8">
                <textarea name="url" class="form-control" required></textarea>
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">是否是外链，1是。0不是：</label>
            <div class="col-sm-8">
                <input name="isExt" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否显示头部：</label>
            <div class="col-sm-8">
                <input name="showTitle" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">有效期 开始时间：</label>
            <div class="col-sm-8">
                <input name="startedAt" class="form-control" type="date" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">有效期 结束时间：</label>
            <div class="col-sm-8">
                <input name="expiredIn" class="form-control" type="date" required>
            </div>
        </div>
       <!-- <div class="form-group">
            <label class="col-sm-3 control-label">状态 1上架; 0下架：</label>
            <div class="col-sm-8">
                <div class="radio-box">
                    <input type="radio" name="status" value="" required>
                  &lt;!&ndash;  <label th:for="status" th:text="未知"></label>&ndash;&gt;
                </div>
              &lt;!&ndash;  <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>&ndash;&gt;
            </div>
        </div>-->
        <!--<div class="form-group">
            <label class="col-sm-3 control-label">修改时间：</label>
            <div class="col-sm-8">
                <input name="modifiedAt" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间：</label>
            <div class="col-sm-8">
                <input name="createdAt" class="form-control" type="text" required>
            </div>
        </div>-->
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
    var prefix = ctx + "system/info"



    //文件上传
    function uploadFile() {
        var form = $("#form-info-add")[0];
        var formData = new FormData(form);
            /*formData.append('file', files[0]);*/
        if ($('#filePath')[0].files[0] == null){
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
        formData.append('file',$('#filePath')[0].files[0]);
        formData.append('hideinfo',$('#hideinfo')[0]);
        $.ajax({
            url: prefix + "/add",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function(result) {
                console.log(result)
                setTimeout(function(){
                    $.modal.close();
                },300);
                var parent = window.parent;
                parent.$.modal.msgSuccess("操作成功!");
                parent.$.table.refresh();
            }
        });
    }

    //表单校验
    $("#form-info-add").validate({
        focusCleanup: true
    });

    //表单提交
    function submitHandler() {
        if ($.validate.form()) {
            uploadFile();
        }
    }

    function adpost() {
        var url=prefix+"/addadpos";
        $.modal.open("查看通知公告",url,'900','600');//900页面宽度  600页面高度
        //$.modal.open弹出框打开
    }
</script>
</body>
</html>